/*    */ package handling.login.handler;
/*    */ 
/*    */ import client.MapleClient;
/*    */ import handling.opcode.SendPacketOpcode;
/*    */ import org.apache.logging.log4j.LogManager;
/*    */ import org.apache.logging.log4j.Logger;
/*    */ import tools.StringUtil;
/*    */ import tools.data.input.LittleEndianAccessor;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class PacketErrorHandler
/*    */ {
/* 19 */   private static final Logger log = LogManager.getLogger("PacketErrorLog");
/*    */   
/*    */   public static void handlePacket(LittleEndianAccessor slea, MapleClient c) {
/* 22 */     if (slea.available() >= 6L) {
/* 23 */       short mode = slea.readShort();
/* 24 */       slea.skip(4);
/* 25 */       short badPacketSize = slea.readShort();
/* 26 */       slea.skip(4);
/* 27 */       int pHeader = slea.readShort();
/* 28 */       String pHeaderStr = Integer.toHexString(pHeader).toUpperCase();
/* 29 */       pHeaderStr = StringUtil.getLeftPaddedStr(pHeaderStr, '0', 4);
/* 30 */       String op = lookupRecv(pHeader);
/* 31 */       String from = "";
/* 32 */       if (c.getPlayer() != null) {
/* 33 */         from = " 角色: " + c.getPlayer().getName() + " 等级(" + c.getPlayer().getLevel() + ") 职业: " + c.getPlayer().getJob() + " 地图: " + c.getPlayer().getMapId() + " \r\n";
/*    */       }
/* 35 */       String Recv = "mode:" + mode + "  处理Recv封包出错: " + op + " [" + pHeaderStr + "] (" + (badPacketSize - 4) + ")\r\n包头: 0x" + pHeaderStr + slea.toString();
/* 36 */       log.error(from + Recv);
/*    */     } 
/*    */   }
/*    */   
/*    */   private static String lookupRecv(int val) {
/* 41 */     for (SendPacketOpcode op : SendPacketOpcode.values()) {
/* 42 */       if (op.getValue() == val) {
/* 43 */         return op.name();
/*    */       }
/*    */     } 
/* 46 */     return "UNKNOWN";
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\handling\login\handler\PacketErrorHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */